build: Allow ostree to use g_autoptr on its types internally
authorKrzesimir Nowak <krzesimir@kinvolk.io>
Fri, 13 May 2016 06:08:49 +0000 (08:08 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 17 May 2016 21:13:20 +0000 (21:13 +0000)
As an example, I g_autoptred one OstreeRepo in the "ostree init"
command.

Closes: #295
Approved by: cgwalters

Makefile.am
src/libostree/ostree-autocleanups.h
src/ostree/ot-builtin-init.c

index a003af25363593cc1d6d7b4b86a37c62f1276aea..1de3154444a470a0db1dd8225f235fb2a1f6220a 100644 (file)
@@ -24,6 +24,7 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
        -DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \
        -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \
        -DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \
+       -DOSTREE_COMPILATION \
        -DG_LOG_DOMAIN=\"OSTree\" \
        -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 \
        -DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48
index d04ba9aa1c5c6ce9cbeb559ff788f39f5dd65bb6..7301ef1d702a8d373f33b4e99d186761826edd07 100644 (file)
@@ -30,7 +30,10 @@ G_BEGIN_DECLS
 #define OSTREE_WITH_AUTOCLEANUPS 0
 #endif
 
-#if OSTREE_WITH_AUTOCLEANUPS && GLIB_CHECK_VERSION(2, 44, 0)
+/* ostree can use g_autoptr backports from libglnx when glib is too
+ * old, but still avoid exposing them to users that also have an old
+ * glib */
+#if defined(OSTREE_COMPILATION) || (OSTREE_WITH_AUTOCLEANUPS && GLIB_CHECK_VERSION(2, 44, 0))
 
 /*
  * The following types have no specific clear/free/unref functions, so
index 9e7c8a2bfedfe8a1e612eda87ca23ca252cfb878..a250b793488b6b1f0e86d412e0974bb5629b8a3f 100644 (file)
@@ -37,7 +37,7 @@ gboolean
 ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context = NULL;
-  glnx_unref_object OstreeRepo *repo = NULL;
+  g_autoptr(OstreeRepo) repo = NULL;
   gboolean ret = FALSE;
   OstreeRepoMode mode;